<template>
  <div class="stat-cards">
    <div
      v-for="(item, idx) in stats"
      :key="item.title"
      :class="['stat-card', { active: activeCard === idx }]"
      @click="handleCardClick(idx)"
    >
      <div class="stat-title">
        <i :class="item.icon" class="stat-icon"></i>
        {{ item.title }}
      </div>
      <div class="stat-count">{{ item.count }}</div>
    </div>
 
  </div>

</template>

<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
const activeCard = ref(0)
const stats = [
  { title: '全部', count: '999+', icon: 'el-icon-menu', type: 'all' },
  { title: '比赛获奖', count: '999+', icon: 'el-icon-trophy', type: 'competition' },
  { title: '论文', count: '999+', icon: 'el-icon-user', type: 'paper' },
  { title: '专利', count: '999+', icon: 'el-icon-coin', type: 'patent' },
  { title: '软著', count: '999+', icon: 'el-icon-suitcase', type: 'software' }
]
defineProps({
  total: {
    type: Number,
    default: 0
  }
})
const emit = defineEmits(['filter'])

const handleCardClick = (idx) => {
  activeCard.value = idx
  emit('filter', stats[idx].type)
  ElMessage({
    message: `已切换到${stats[idx].title}分类`,
    type: 'success',
    duration: 1500
  })
}

</script>

<style scoped>
.stat-cards {
  display: flex;
  gap: 24px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 180px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  text-align: center;
  padding: 28px 0 24px 0;
  font-size: 20px;
  color: #222;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #7ac143 0%, #8edc5a 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card.active {
  background: linear-gradient(135deg, #7ac143 0%, #8edc5a 100%);
  color: #fff;
  border: 2px solid #7ac143;
  box-shadow: 0 8px 24px rgba(122, 193, 67, 0.2);
  transform: translateY(-4px);
}

.stat-title {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 22px;
  margin-bottom: 12px;
}

.stat-icon {
  font-size: 32px;
  margin-right: 12px;
  transition: all 0.3s ease;
}

.stat-card:hover .stat-icon {
  transform: scale(1.1) rotate(5deg);
}

.stat-count {
  font-size: 36px;
  font-weight: bold;
  margin-top: 12px;
  background: linear-gradient(90deg, #333 0%, #666 100%);
  background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: all 0.3s ease;
}

.stat-card.active .stat-count {
  background: linear-gradient(90deg, #fff 0%, #f0f0f0 100%);
  background-clip: text;
  -webkit-text-fill-color: transparent;
  transform: scale(1.1);
}

@media screen and (max-width: 768px) {
  .stat-cards {
    gap: 16px;
    margin-bottom: 24px;
  }

  .stat-card {
    flex: 0 0 calc(33.33% - 11px);
    min-width: 0;
    padding: 20px 0 16px 0;
  }

  .stat-title {
    font-size: 18px;
    margin-bottom: 8px;
  }

  .stat-icon {
    font-size: 24px;
    margin-right: 8px;
  }

  .stat-count {
    font-size: 28px;
  margin-top: 8px;
  }
}

@media screen and (max-width: 480px) {
  .stat-cards {
    gap: 12px;
  }

  .stat-card {
    flex: 0 0 calc(50% - 6px);
  }
}
</style> 